#pragma once

#include <string>
#include <assert.h>
#include <SockOpt.h>

class InetAddress{
public:

    // 自动分配一个ip和port
    InetAddress() {
        addr_.sin_addr.s_addr = INADDR_ANY;
        addr_.sin_port = 0;
		addr_.sin_family = AF_INET;
	}

    InetAddress(const sockaddr& addr);
    
    InetAddress(const std::string& addr, uint16_t port);

    const sockaddr_in& getSockAddr() const { return addr_; }

    uint16_t port();

    std::string ip();

private:
    std::string ip_;
    uint16_t port_;
    sockaddr_in addr_;
};